{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "078eb597",
   "metadata": {},
   "source": [
    "上机3-01:\n",
    "\n",
    "编写斐波那契数列函数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0510d48c",
   "metadata": {},
   "outputs": [],
   "source": [
    "def fibonacci(n):\n",
    "    if n == 0:\n",
    "        return 0\n",
    "    elif n == 1:\n",
    "        return 1\n",
    "    return fibonacci(n-1) + fibonacci(n-2)\n",
    "\n",
    "for n in range(11):\n",
    "    print(f\"F{n}: {fibonacci(n)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fc54bef0",
   "metadata": {},
   "source": [
    "上机3-02:\n",
    "\n",
    "定义一个由整数组成的列表，其中包含10个元素，分别赋值为1～10，然后将列表中的元素依次向前移一个位置，即，原来是 [1,2,3,4,5,6.7,8,9.10]，变成：[2.3,4,5,6.7,8,9.10.1]，然后输出这个数组。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "d7371e61",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "original_lst: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n",
      "shifted_lst: [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]\n"
     ]
    }
   ],
   "source": [
    "def shift_left_slice(lst):\n",
    "    return lst[1:] + lst[:1]\n",
    "\n",
    "original_lst = list(range(1, 11))\n",
    "shifted_lst = shift_left_slice(original_lst)\n",
    "\n",
    "print(f\"original_lst: {original_lst}\")\n",
    "print(f\"shifted_lst: {shifted_lst}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
